<template>
	<view class="content">
            <image :src="$domain.api+detail.cover_image" mode="widthFix"></image>
            <view class="bgWhite plr15 ptb15 box">
                <view class="title">
                        {{detail.title}}
                </view>
                <view class="">
                    地址： {{detail.address}}
                </view>
                <view class="">
                    比赛时间： {{detail.arena_time}}
                </view>
                <view class="">
                    报名截止时间： {{detail.end_time}}
                </view>
            </view>
            
            <view class="mt10 bgWhite  plr15 ptb15">
                <view class="title mb10">
                        赛事说明
                </view>
                <uv-parse :content="detail.content"></uv-parse>
            </view>
				
	</view>
</template>

<script>
	export default {
		data() {
			return {
				content:"",
                detail:{}
			};
		},
        onLoad(opt) {
            
            if(opt.id){
                this.id = opt.id
                this.getDetail()
                
                
            }
        },
		methods: {
          
            async  getDetail(){
              const data = await  this.$api.articleMain({id:Number(this.id)})
             console.log(data)
             this.detail = data
            
            },
			//添加照片
			addImgBtn() {
				this.$refs.addCarImg.open();
			},
			coleAddImg(){
				this.$refs.addCarImg.close();
			},
			//合同按钮
			contractBtn() {
				this.$refs.dzContract.open();
			},
			//合同弹窗关闭
			contractClose() {
				this.$refs.dzContract.close();
			},
			//更多照片
			moreImg() {
				this.$refs.checkCar.open();
			},
			//验证车弹窗关闭
			carImgClose() {
				this.$refs.checkCar.close();
			},
            async getCartImg(){
                    const {data}  =   await  this.$api.cartImage({order_id:this.id})
                    
                    this.imgList = data.list
                    
            },
            uploadFile (type, directory) {
              let vm = this
              uni.chooseImage({
                count: 1, //最多可以选择的图片总数
                // sizeType: sizeType, // 可以指定是原图还是压缩图，默认二者都有
                // sourceType: sourceType, // 可以指定来源是相册还是相机，默认二者都有
                success: async (res) => {
                  let data = {
                    filePath: res.tempFilePaths[0],
                    formData: {
                      directory
                    },
                    header: {
                        // #ifdef MP
                        'Content-Type': 'application/x-www-form-urlencoded',
                        // #endif
                      'Token': uni.getStorageSync('logintoken')
                    }
                  }
                  vm.$api.uploadImg(data).then(res => {
                        vm.form.pay_image=res.fullurl
                  })
                },
              })
            },
            addCarImgdata(){
                    
                    if(!this.form.pay_image) return this.$utils.msg('请上传支付凭证')
                    uni.showLoading({
                        title:'加载中'
                    })
                    this.$api.addPayImage(this.form).then(res=>{
                        uni.hideLoading()
                        
                        if(res.code==1){
                            this.$utils.msg('添加成功')
                            setTimeout(()=>{
                                uni.reLaunch({
                                    url:'/pages/tabbar/myOrder'
                                })
                            },800)
                        }else{
                            this.$utils.msg(res.msg)
                        }
                    })
                    
            }
		}
	}
</script>

<style lang="scss" scoped>
	.content{
        image{
            width: 100%;
        }
        .box{
                margin-top: -30rpx;
                position: relative;
                border-radius: 30rpx 30rpx 0 0;
                font-size: 30rpx;
                color: #666666;
                line-height: 46rpx;
        }
        .title{
            
            font-weight: bold;
           font-size: 32rpx;
           color: #1C1C1C;
       }
    }
</style>